#pragma GCC optimize(2)
#include <iostream>
#include <math.h>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
#define endl '\n'
#define int long long
bool compare(const pair<string, int> &a, const pair<string, int> &b)
{
    if (a.second == b.second)
        return a.first < b.first;
    else
        return a.second > b.second;
}
void test()
{
    int n;
    int tem;
    cin >> n;
    int c[2000];
    for (size_t i = 0; i < n; i++)
    {
        cin >> c[i];
    }
    map<string, int> m{{"res1", c[0]}, {"res2", c[1]}, {"res3", c[2]}, {"res4", c[3]}};
    string min;
    for (int i = 4; i < n; i++)
    {
        vector<pair<string, int>> v(m.begin(), m.end());
        sort(v.begin(), v.end(), compare);
        min = v[3].first;
        m[min] += c[i];
    }
    vector<pair<string, int>> v(m.begin(), m.end());
    sort(v.begin(), v.end(), compare);
    min = v[0].first;
    cout << m[min];
}

signed main()
{
    test();
    return 0;
}
